#include <iostream>
#include <string>
#include "../Headers/types.h"

#include "tui.email.h"
#include "tui.utils.h"

// Send mail
void tuiEMSend(TOB::Shell &shell, std::string &username, std::string &body) {
  if(username.size() == 0) return shell.wrongParam("Username");  
}

// Delete letter
void tuiEMDelete(TOB::Shell &shell, uint32 id) {
}

// Get all mail
void tuiEMAllMail(TOB::Shell &shell) {
}

// Check new mail
void tuiEMCheckMail(TOB::Shell &shell) {
}

// Expand space
void tuiEMExpand(TOB::Shell &shell, uint32 size) {
}

// Read mail
void tuiEMRead(TOB::Shell &shell, uint32 id) {
}

// E-Mail
void tuiEMail(TOB::Shell &shell, std::stringstream &stream) {
  uint32 id;
  std::string action, uname;
  stream >> action;

  if(action == "send") {
    action = "";
    stream >> uname;
    readStreamToEnd(stream, action); 
    tuiEMSend(shell, uname, action);

  } else if(action == "delete") {
    stream >> id;
    tuiEMDelete(shell, id);
  
  } else if(action == "all") {
    tuiEMAllMail(shell);
  
  } else if(action == "check") {
    tuiEMCheckMail(shell);
  
  } else if(action == "expand") {
    stream >> id;
    tuiEMExpand(shell, id);
  
  } else if(action == "read") {
    stream >> id;
    tuiEMRead(shell, id);
  
  } else {
    shell.write("Using: {send|delete|all|check|expand|read} [username [message_body]|letter_id]").writeLine();

  }
}
